package com.example.entity.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum UserCouponStatusEnum implements BaseEnum{
    UNUSED(0, "未使用"),
    USED(1, "已使用"),
    EXPIRED(2, "已过期");
    @EnumValue
    private final int value;
    private final String desc;


    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static UserCouponStatusEnum of(Integer value) {
        if (value == null) {
            return null;
        }
        for (UserCouponStatusEnum status : values()) {
            if (status.value == value) {
                return status;
            }
        }
        return null;
    }

    public static String desc(Integer value) {
        UserCouponStatusEnum status = of(value);
        return status == null ? "" : status.desc;
    }
}
